package com.example.agriculturemachine.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.agriculturemachine.R;



import butterknife.ButterKnife;
import butterknife.Unbinder;

public class BaseFragment extends Fragment {

    private Unbinder mBind;

    @Override
    public View onCreateView(@NonNull  LayoutInflater inflater, @Nullable  ViewGroup container, @Nullable Bundle savedInstanceState) {

        View rootView = loadRootView(inflater, container);
        mBind = ButterKnife.bind(this, rootView);

        initView();
        initEvent();
        //加载状态view
        //loadStatesView(inflater,container);

        return rootView;
    }

    private void loadStatesView(LayoutInflater inflater, ViewGroup container) {

    }

    //枚举类
    public enum State{
        SELECT,END,SUCCESS,ERROR
    }

    //默认加载的view
    protected View loadRootView(LayoutInflater inflater, ViewGroup container) {
        return inflater.inflate(R.layout.base_fragment_layout,container,false);
    }
    protected void initView(){

    }

    protected void initEvent(){

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if(mBind!=null){
            mBind.unbind();
        }

    }
}
